<?php

class CartWidget extends CWidget
{
    public function run()
    {
        if(Yii::app()->cart->hesProducts) $products=Yii::app()->cart->products;
        else $products=array();

        $itemsProvider=new CArrayDataProvider($products, array(
            'pagination'=>array(
                'pageSize'=>Yii::app()->params['elementsPerPage'],
            ),
        ));

        unset($products);

        $this->render('cartWidget', array(
            'itemsProvider'=>$itemsProvider,
        ));
    }
}